#ifndef TRADERMAIN_H_
#define TRADERMAIN_H_
#pragma once

//(in)this part used for trademain.cpp
//(out)this part used for main.h
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include "windows.h"
#include "traderspi.h"
#include "traderapi.h"


//(out)this part used for main.h

//typedef struct UserLogin
//{
//	TThostFtdcBrokerIDType	BrokerID;
//	TThostFtdcUserIDType	UserID; 
//	TThostFtdcPasswordType	Password;
//}UserLogin;

class CTrade
{
public:
	CTrade(CtpTraderApi* papi, CtpTraderSpi* pspi):m_papi(papi), m_pspi(pspi){};
	~CTrade()
	{
		if (NULL != m_papi)
		{
			delete m_papi;
			m_papi = NULL;
		}
			

		if (NULL != m_pspi)
		{
			delete m_pspi;
			m_pspi = NULL;
		}
			
	};

public:
	CtpTraderApi* m_papi;
	CtpTraderSpi* m_pspi;
};

typedef struct InstInfo
{
	InstInfo(char* cinst, double p, double v, double pre)
	{
		memset(inst, 0, sizeof(inst));

		strcpy(inst, cinst);

		pricetick = p;

		volumn = v;

		preOpenInterest = pre;
	}

	InstInfo(const InstInfo& source)
	{
		memset(inst, 0, sizeof(inst));

		strcpy(inst, source.inst);

		pricetick = source.pricetick;

		volumn = source.volumn;

		preOpenInterest = source.preOpenInterest;
	}

	char inst[10];

	double pricetick;

	double volumn;

	double preOpenInterest;


} InstInfo;


//bool td_main_login(char* pborkeid, char* puserid, char* ppassword, char* pTDFront, unsigned int flag, CTrade* &ptrade);
//
//bool td_main_logout(CTrade* &ptrade);

bool GetTradingDay_InstRead(char* pborkeid, char* puserid, char* ppassword, char* pTDFront, unsigned int flag);

bool GetInstWrite(char* pborkeid, char* puserid, char* ppassword, char* pTDFront, unsigned int flag);



#endif